<template>
  <div>
    <!-- 错误详情 -->
    <el-dialog
      width="800px"
      title="错误详情"
      destroy-on-close
      append-to-body
      :visible.sync="show"
      :before-close="cancel"
    >
      <el-descriptions :column="1" border>
        <el-descriptions-item label="订单号"> 错误描述 </el-descriptions-item>
        <el-descriptions-item
          :key="key"
          :label="key"
          v-for="(item, key) in formData"
        >
          {{ item }}
        </el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  activated() {
    this.$nextTick(() => this.$refs['TableRef']?.doLayout())
  },
  props: {
    /**
     * formData
     */
    formData: {
      type: Object,
      default: {},
    },
    /**
     * 控制显示隐藏
     */
    show: {
      type: Boolean,
      required: true,
      default: false,
    },
  },
  data() {
    return {
      form: {},
      // 表单校验
      rules: {
        distrName: [{ required: true, message: "请输入", trigger: "blur" }],
      },
    };
  },
  computed: {},
  watch: {
    show: function (newValue) {
      if (newValue) {
        this.resetForm();
      }
    },
  },
  methods: {
    handleSubmit() {
      this.$refs["formRef"].validate((valid) => {
        if (valid) {
        }
      });
    },
    resetForm() {
      Object.keys(this.form).forEach((key) => (this.form[key] = ""));
    },

    cancel() {
      this.$emit("update:show", false);
    },
  },
};
</script>
<style scoped lang="scss"></style>
